package com.prince.bean;


import com.prince.bean.Response;
import com.prince.bean.ResultParams;

public class CommonWebResponse {
    public static ResultParams getResponseCodeMsgParams(WebCode codeMsg) {
        ResultParams params = new ResultParams();
        params.put(CommonWebParamKeys.RETURN_CODE, codeMsg.code);
        params.put(CommonWebParamKeys.RETURN_MSG, codeMsg.msg);
        return params;
    }

    public static ResultParams getResponseCodeMsgParams(String code, String msg) {
        ResultParams params = new ResultParams();
        params.put(CommonWebParamKeys.RETURN_CODE, code);
        params.put(CommonWebParamKeys.RETURN_MSG, msg);
        return params;
    }
    public static ResultParams getResponseCodeMsgParams(Response<?> response) {
        return CommonWebResponse.getResponseCodeMsgParams(
                response.getStatus().toString(),
                response.getErr());
    }

    /**
     * App获取code及msg的统一响应
     *
     * @return
     */
    public static ResultParams getRespAppParams(String code, String msg) {
        return getResponseCodeMsgParams(code,msg);
    }
    
    /**
     * 获取code及msg的统一响应
     *
     * @return
     */
    public static ResultParams getCommonRespCodeMsgParams(WebCode WebCode) {
        return getResponseCodeMsgParams(WebCode);
    }
    
    
    /**
     * 后台系统 获取标记成功code及msg的统一响应
     *
     * @return
     */
    public static ResultParams getSuccessResponseCodeMsgParams() {
        return getResponseCodeMsgParams(WebCode.success);
    }


    /**
     * 后台系统 获取标记签名错误的code及msg的统一响应
     *
     * @return
     */
    public static ResultParams getSignErrorResponseCodeMsgParams() {
        return getResponseCodeMsgParams(WebCode.signError);
    }

    /**
     * 获取标记参数错误的code及msg的统一响应
     *
     * @return
     */
    public static ResultParams getParamsErrorResponseCodeMsgParams() {
        return getResponseCodeMsgParams(WebCode.paramsError);
    }

    /**
     * 获取标记签名错误的code及msg的统一响应
     *
     * @return
     */
    public static ResultParams getSystemErrorResponseCodeMsgParams() {
        return getResponseCodeMsgParams(WebCode.systemError);
    }

    /**
     * 用户未登录认证错误的code及msg的统一响应
     *
     * @return
     */
    public static ResultParams getAuthenticationError() {
        return getResponseCodeMsgParams(WebCode.authenticationError);
    }
}
